package my.edu.model.bills.sales.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import my.edu.common.myInterface.AccountCount;
import my.edu.common.myInterface.CanAudit;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@TableName("sales_return_order")
public class SalesReturnOrder implements CanAudit, AccountCount {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String orderNo;
    private Long customerId;
    private String customerName;
    private Long salespersonId;
    private String salespersonName;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate orderDate;
    private String customerAddress;
    private Integer isAudited;
    private String refundStatus;//退款状态
    private Integer quantity;
    private BigDecimal discountRate;
    private BigDecimal discountAmount;//收款优惠
    private BigDecimal amountAfterDiscount;
    private BigDecimal reSalesAmount;//所有退款金额
    private Long settlementAccountId;
    private String settlementAccountName;
    private BigDecimal debt;
    private BigDecimal reReceivedAmount;//已退款
    private Long salesExpenseId;
    private Long salesOrderId;
    private String salesOrderNo;
    private Integer sourcePurchaseQuantity;
    private String deliveryMethod;
    @TableField(fill = FieldFill.INSERT)
    private Long createdBy;
    @TableField(fill = FieldFill.INSERT)
    private String createdName;
    private Long auditorId;
    private String auditorName;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;
    @TableField(fill = FieldFill.UPDATE)
    private String updateName;
    private String remark;//备注
    private String logisticsNo;

    @Version
    private Integer version;

    @Override
    public BigDecimal getCirculatingMoney() {
        return reReceivedAmount;
    }
}